<div class="g12 nodrop" style="margin-bottom: 43px;">

    <h1> <? if (isset($_GET['id'])) {echo 'Ažuriranje direktorijuma'; } else echo 'Novi direkotijum' ?> </h1>

    <!--FORM-->    
    <div style="width: 100%;">

        <div id="srvrserror-3"></div>

        <button id="dialog_confirm" style="display: none;">Confirm Dialog (confirm)</button>

        <form action="javascript:" method="post" autocomplete="off" data-confirm-send="false">

        <fieldset>

        <section><label for="input">Naziv</label>
            <div><input type="text" id="name" name="name" required value="<? if (isset($directoryData)) echo $directoryData[0]['name']; ?>"></div>
        </section>

        <section><label for="input">Opis - (Interni text za laksu identifikaciju)</label>
            <div><input type="text" id="description" name="description" required value="<? if (isset($directoryData)) echo $directoryData[0]['description']; ?>"></div>
        </section>

        <section><label for="input">Direktorijum</label>
            <div>

                <!-- DVA SELECT BOXA SU ISTA RADI PROVJERE ISSET PROMJENJLJIVE PHP -->
            
                <?
                    if(isset($directoryData)){
                        if(($directoryData[0]['id']==2)||($directoryData[0]['id']==3)||($directoryData[0]['id']==4)){
                            echo $directoryData[0]['name'];
                        }else{?> 
                        <select name="directory" id="directory" style="color: #555555; line-height: 16px; padding: 3px 0 0 3px; width: 17em;">
                            <option value="0">-- Molim odaberite</option> 
                            <?
                                foreach($directoryMedia as $directory){

                                ?><option value="<?=$directory['id'];?>" <?  if (isset($directoryData)){if(($directoryData[0]['parent']==$directory['id'])){ echo 'selected=selected';}} ?>><?=$directory['name'];?></option><?

                                }
                            ?>
                        </select>
                        <?}
                    }else{?>

                    <select name="directory" id="directory" style="color: #555555; line-height: 16px; padding: 3px 0 0 3px; width: 17em;">
                        <option value="0">-- Molim odaberite</option> 
                        <?
                            foreach($directoryMedia as $directory){

                            ?><option value="<?=$directory['id'];?>" <?  if (isset($directoryData)){if(($directoryData[0]['parent']==$directory['id'])){ echo 'selected=selected';}} ?>><?=$directory['name'];?></option><?

                            }
                        ?>
                    </select>

                    <?}
                ?>


            </div>
        </section>

        <section>
        <button class="submit small" onclick="return false;"><? if (isset($_GET['id'])) {echo 'Ažuriraj direktorijum'; }else echo 'Kreiraj direktorijum'; ?></button></div>
    </section> 

    </fieldset>

    </form>

</div>

</div>

<!-- VARIABLES TO edit_new.js -->
<script type="text/javascript">
    var appmode;
    var get_id;
    var parent;
    <?  if (isset($_GET['id'])){ ?> 
        appmode = 'edit';
        get_id = '<?=$_GET['id']?>';
        parent = '<?=$directoryData[0]['id']?>';

        <?}else{?> 
        appmode = 'insert'; 
        get_id = -1;
        <? } ?>
</script>
<style>
    #uniform-directory span{
        width: 17em;
    }
</style>